import React from 'react'
import '../views/FillOrder/FillOrder.less'
import { withRouter } from 'react-router-dom'
class Address extends React.Component {
    goAdd = (id, e) => {
        // console.log(id,e)
        this.props.history.push(`/AddAddress/${id}`)
        // e.nativeEvent.stopImmediatePropagation();
    }
    goBack(val) {
        console.log(this.props)
        if (this.props.match.params.goodsId == 0) { return }
        if (this.props.match.path === '/AllAddress/:ID/:commonId/:goodsId/:num/:addressId/:inviteCode') {
            this.props.history.push(`/FillOrder/${this.props.match.params.ID}/${this.props.match.params.commonId}/${this.props.match.params.goodsId}/${this.props.match.params.num}/${val}/${this.props.match.params.inviteCode}`)
        }
    }
    render() {
        return (
            <div className='Address-d1'>
                {this.props.index === 0 ? <img className='Address-i1' src={require('../static/img/order1.png')} alt="" /> : <img></img>}
                <div className='Address-d2'>
                    <div className='Address-d3 center' onClick={this.goBack.bind(this, this.props.address.id)}>
                        <p>{this.props.address.receiver || this.props.address.person}</p>
                        {this.props.address.defaultAddress == 1 ? <p className='center'>默认</p> : <div></div>}
                    </div>
                    <div className='Address-d4' onClick={this.goBack.bind(this, this.props.address.id)}>
                        <p>{this.props.address.phone}</p>
                        <p>{this.props.address.details || this.props.address.address}</p>
                    </div>
                    {this.props.ID == 1 ? <img onClick={this.goAdd.bind(this, this.props.address.id)} className='Address-i2' src={require("../static/img/order2.png")} alt="" /> : <div></div>}
                </div>
            </div>
        )
    }
}

export default withRouter(Address)